package edu.gatech.coc.sirana.detection;

//import java.text.ParseException;
import java.util.ArrayList;

import edu.gatech.coc.sirana.exception.SIRANAException;
//import edu.gatech.coc.sirana.graph.InteractionCycle;
//import edu.gatech.coc.sirana.graph.SRCycles;
//import edu.gatech.coc.sirana.parser.ClientLogItem;
//import net.util.Out;

public class SRCycleAttribute implements Comparable<SRCycleAttribute> {
	private ArrayList<String> events;
	private int numRepeated;	
	private String id;
	
	public SRCycleAttribute(String id, int repetition, ArrayList<String> events){
		this.setEvents(events);
		this.setNumRepeated(repetition);
		this.setId(id);
	}	

	public ArrayList<String> getEvents() {
		return events;
	}
	
	public String findEventString(){
		StringBuffer sb = new StringBuffer();
		for (String e : getEvents()){
			char eCode = 0;
			if (e.equals("enter")) eCode = 1;
			else if (e.equals("click")) eCode = 2;
			else if (e.endsWith("change")) eCode = 3;
			else if (e.equals("focus")) eCode = 4;
			else throw new SIRANAException("Wrong Event for coding!");
			
			sb.append(eCode);
		}
		
		return sb.toString();
	}

	public void setEvents(ArrayList<String> events) {
		this.events = events;
	}
	
	public int getNumRepeated() {
		return numRepeated;
	}
	public void setNumRepeated(int numRepeated) {
		this.numRepeated = numRepeated;
	}
	
	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}

	public String toString(){
		StringBuffer sb = new StringBuffer();
		
		sb.append(id + ", " + this.numRepeated + ", " + this.getEvents().toString());		
		return sb.toString();
	}


	@Override
	public int compareTo(SRCycleAttribute s) {
		return this.getEvents().toString().compareTo(s.getEvents().toString());		
	}
//	
//	private int compareEventSize(SRCycleAttribute s){
//		if (this.getEvents().size() > s.getEvents().size()) return 1;
//		else if (this.getEvents().size() < s.getEvents().size()) return -1;
//		else return 0;
//	}
}
